home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-12-10 | 3.2 KB | 117 lines | [TEXT/KAHL] |
- CTrace README
-
- This is a revamp of the CTrace upload I submitted from the article:
-
- CTRACE: A MESSAGE LOGGING CLASS
- by William D. Cramer, Dr. Dobbs Journal #170 (November 1990),
- p. 44-55, 116-120.
-
- I have put the different source code in their proper files and
- have constructed a proper .rsrc file for the TestApp. Here are
- a few important points from the article to properly implement CTrace
- in your application.
-
- RESOURCES
- I copied and modified the resource file Pedestal.π.rsrc into which I put:
-
- Resource ID Type Description
-
- 2000 MENU Titled "Trace", with the items
- Show (command 2000) and
- Mask (command 2001)
- NB: make sure in ResEdit to use the "Menu" Menu to
- "Edit Menu & MDEF ID..." to 2000 and 1 respectively
-
- 1 MBAR add menu res ID 2000
-
- 2000 DLOG coordinates (14,34), (508,286)
- procID 1, marked as visible,
- linked to DITL 2000
- 2000 DITL buttons OK and Cancel (items 1 and 2)
- checkboxes Errors, Warnings, Info,
- Function Entry, Function Exit (items
- 3 through 7), plus 27 additional
- checkboxes (items 8 through 34)
- titled Undefined and marked as disabled
- (you edit these yourself for your trace
- masks)
- 2000 WIND titled "Trace Log" at coordinates
- (16,52) (330, 220), procID 8, marked
- as not visible, with goAwayFlag enabled.
-
-
- TRACE MASKS
-
- You define the up to 32 trace masks (5 of which are already defined).
- You define a new hex trace mask in CTrace.h such as,
-
- #define T_PICT_REDRAW (0x00002000) /* screen refresh logging */
-
- then, for example, insert the following code at the desired point
-
- gTrace->Trace( T_PICT_REDRAW, "Refreshing the screen" );
-
- or,
-
- gTrace->Trace( T_FUNC_IN, "Entering LoopEndlessly() method" );
-
- If you add a new mask you should change a DITL checkbox for your new mask.
- DITL #3 corresponds to 0x00000001, DITL #4 corresponds to 0x00000002, etc.
-
-
- ADDING CTrace TO CApplication
-
- struct CYourApp : CApplication {
- CTrace *itsTraceLog;
- ...
- };
-
-
- INITIALIZING CTrace
-
- itsTraceLog = new ( CTrace );
- itsTraceLog->ITrace( numberOfRecordsToLog );
-
-
-
- ADDITIONS TO UpdateMenus() METHOD FOR YOUR APPLICATION
-
- /** UpdateMenus -- Updates the Trace portion of the menus. **/
- void CTestApp::UpdateMenus (void)
- {
- inherited::UpdateMenus ();
- gBartender->EnableMenu (TRACE_MENU_ID);
- gBartender->EnableCmd (TRACE_MENU_SHOW);
- gBartender->EnableCmd (TRACE_MENU_MASK);
- if (itsTraceLog->IsItVisible ())
- gBartender->CheckMarkCmd (TRACE_MENU_SHOW, TRUE);
- else
- gBartender->CheckMarkCmd (TRACE_MENU_SHOW, FALSE);
- }
-
-
- ADDITIONS TO DoCommand() METHOD FOR YOUR APPLICATION
-
- case TRACE_MENU_SHOW :
- itsTraceLog->ToggleTraceWindow ();
- break;
- case TRACE_MENU_MASK :
- itsTraceLog->SetTraceMask ();
- break;
- default :
- inherited::DoCommand (command);
-
-
- OTHER NOTES
- The gTrace->Trace() method uses varargs() which can have up to 200 characters.
- The author suggests that once debugging is completed, you can leave the Trace
- object in your code but just edit the MBAR resource so that the Trace menu
- doesn't show up. Since the default trace mask is empty, you don't use up any
- memory, and you can just add the resource back if you decide to debug again.
-
- I hope this is useful. Get the article if you have further questions.
- Cheers,
-
- David McCormick
- MIT-EAPS Geology
- dmac@athena.mit.edu